var removeDuplicates = function(nums) {
  // let i = 0
  // let n = nums.length
  // while(i<n) {
  //   if(nums.indexOf(nums[i])===i) {
  //     i++
  //     continue
  //   }
  //   nums.splice(i,1)
  //   n = nums.length
  // }
  let n = nums.length
  let fast = 2
  //记录待插入的位置
  let slow = 2
  while(fast < n) {
    if(nums[fast] !== nums[fast-2]) {
      nums[slow] = nums[fast]
      slow++
    }
    fast++
  }
  return slow
};
console.log(removeDuplicates([0,0,1,1,1,2,2,3,3,4]));
